package com.zretc.kscxmz.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.Position;
import com.zretc.kscxmz.mappers.PositionMapper;
import com.zretc.kscxmz.services.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PositionServiceImpl implements PositionService {

    @Autowired
    private PositionMapper PositionMapper;


    @Override
    public PageInfo<Position> getPositionByPage(Map<String, String> param) {
        int pageNum =  Integer.parseInt(param.get("pageNum"));
        int pageSize =  Integer.parseInt(param.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);

        List<Position> list = PositionMapper.findPositionInfo(param);
        PageInfo<Position> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }


    @Override
    public int addPositionInfo(Map<String, Object> param) {

        return PositionMapper.insertPositionInfo(param);
    }

    @Override
    public int updatePositionInfo(Map<String, Object> param) {

        return PositionMapper.updatePositionInfo(param);
    }

    @Override
    public int deletePositionInfo(int PositionId) {
        return PositionMapper.modifyPositionInfoById(PositionId);
    }

    @Override
    public Position getPositionInfoById(int PositionId) {
        return PositionMapper.findPositionInfoById(PositionId);
    }
}
